const app = getApp()
import { detail } from '../../../api/article'

Page({
  data: {
    back: true,
    title: '内容',
    loading: true,
    detail: null
  },
  onLoad(options) {
    this.setData({ loading: true })
    detail(options.id).then(res => {
      let detail = res.data
      detail.content = detail.content.replace(/<img/gi, '<img style="max-width:100%;height:auto;float:left;display:block" ')
      this.setData({ detail: detail })
    })
      .finally(() => {
        this.setData({ loading: false })
      });
  },
  onShow() { },
  onPullDownRefresh() {/*监听用户下拉动作*/ },
  onReachBottom() {/*页面上拉触底事件的处理函数*/ },
  onShareAppMessage(event) {
    return {
      path: '/pages/index/index?share=article&id=' + this.data.detail.id
    }
  }
})